cp.util = function(){};
cp.util.prototype = 
{
		createElement : function(element, elementClassName)
		{
			 return function(x,y){
				 return function(){
					 var elementObj = document.createElement(x);
			         elementObj.className = y;
			         return elementObj;
				 }();
			 }(element,elementClassName);
		},		
		log : function(text)
		{
			if(cp.enableLog)
			{
				$("#logger").append('<div>' + text + '</div>');
			}
		},
		loading : function(flag)
		{
			if(flag)
			{
				$("#loading").html('<div align="center" class="item3"><img  align="middle" src="img/loading.gif" /></div>');
				$("#loading").css("top", 25);
				$("#loading").css("left", cp.winW - 325);
			}
			else
			{
				$("#loading").html('');
			}
		},
		ajaxCall : function(url,callBackFunc,vthis) {
			$.ajax({
				  url: url,
				  type:"get",
				  dataType: "html",
				  success: function(data)
				  {
				      callBackFunc(data,vthis);
				  },
				  error: function(xhr, textStatus, errorThrown){
					  alert(textStatus + " : " + xhr + " : " + errorThrown );
					  $("#loading").html('<div align="center" class="item3"><img  align="middle" src="img/oops.gif" /></div>');
					  $("#loading").css("top", 25);
					  $("#loading").css("left", cp.winW - 325);
				  }
			});
		},
		getComments : function(id)
		{
		},
        setCookie : function (cookieName,cookieValue,cookieExpirationDate)
        {
			chrome.cookies.set({
					url:cp.DOMAIN_URL,
					name:cookieName,
					value:cookieValue,
					expirationDate:cookieExpirationDate
				}
			);
        },
        getCookie : function (cookieName,callBackFnc)
        {
    		chrome.cookies.get(
    				{
    					url:cp.DOMAIN_URL,
    					name:cookieName
    				},
    				function(cookie){
    		            if(callBackFnc){
    		            	if(cookie)
    		            	{
    		            		callBackFnc(cookie.value);
    		            	}
    		            	else
    		            	{
    		            		callBackFnc(cp.USER_COUNTRY);
    		            	}
    		            };
    				}
    		);
        },
        lights: function(lightsOption)
        {
        	switch(lightsOption)
        	{
	        	case cp.LIGHTS_0:
	        	  $(".item3, .item2 , .item1").css("display", "block");
	        	  break;
	        	case cp.LIGHTS_1:
		          $(".item3, .item2").css("display", "block");
		          $(".item1").css("display", "none");
		          break;
	        	case cp.LIGHTS_2:
		          $(".item3").css("display", "block");
		          $(".item1, .item2").css("display", "none");
		          break;
	        	case cp.LIGHTS_3:
		          $(".item3, .item2 , .item1").css("display", "none");
		          break;
	        	default:
	        	  $(".item3, .item2 , .item1").css("display", "block");
        	}
        }
};

cp.util = new cp.util();